﻿package hunterCommonlib.ui {
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	/**
	* ...
	* @author Default
	*/
	public class URLPanel extends Panel {
		protected var _link;
		protected var _window;
		protected var _event
		public function URLPanel() {
			super();
		}
		public function setLink(link:String, event:String, window:String = null):void {
			_link = link;
			_event=event
			_window = window;
			this.addEventListener(event, linkHandler);
		}
		public function clearLink():void {
			if (_link != null){
				this.removeEventListener(_event, linkHandler);
			}
		}
		protected function linkHandler(e:Event) {
			var req:URLRequest = new URLRequest(_link);
			 try {            
                navigateToURL(new URLRequest(_link),_window);
            }
            catch (e:Error) {
              trace(e)
            }
		}
	}
	
}